/**
 * Created by gaoyj on 2018/6/28.
 */
window.onload = function (ev) {
    topbar.hide();
};
buttonShiro("export_Role");
var adminRole = roleCheck();
$('#dataTable').bootstrapTable({
    url: '/supplyCard/findSupplyCardBalancePage',
    height: $(window).height() - 200,
    pageSize: 30,
    pagination: true,
    pageList: [30, 50, 100],
    clickToSelect: true,
    singleSelect: true,
    queryParams: queryParams,
    uniqueId: 'id',
    queryParamsType: '',
    sidePagination: 'server',
    responseHandler: function (res) {
        return {
            "total": res.total,
            "rows": res.resultList
        };
    },
    onClickRow: function (row) {
        if (row.userAccount != null && row.userAccount != '') {
            $("#account_field" + row.userAccount).html(row.userAccount);
        }
    },
    columns: [
        {
            checkbox: true
        },
        {
            align: 'center',
            formatter: function (v, row, index) {
                return index + 1
            }
        },
        {
            field: 'userAccount', title: '会员编号',  align: 'center',
            formatter: function (v, o) {
                return copyAddon(v) + (adminRole == 1 ? v : userAccountHidden(o.userAccount, o.userAccount));
            }
        },
        {
            field: 'userName', title: '会员名称',  align: 'center'
        },
        {
            field: 'status',
            title: '会员状态',
            align: 'center',
            formatter: function (v) {
                return {0: "关闭", 1: "开启"}[v];
            }
        },
        {field: 'pmName', title: '产品经理',  align: 'center'},
        {field: 'balance', title: '可提现金额',  align: 'center'},
        {
            field: 'withdrawStatus',
            title: '提现状态',
            align: 'center',
            formatter: function (v) {
                return {0: "关闭", 1: "开启"}[v];
            }
        }
    ]
});

$("#search").click(function () {
    $("#dataTable").bootstrapTable("refresh");
});
function queryParams(params) {
    return {
        'pageUnit.size': params.pageSize,
        'pageUnit.page': params.pageNumber,
        userAccount: $.trim($("#userAccount").val()),
        status: $("#status").val(),
        withdrawStatus: $("#withdrawStatus").val(),
    };
}

//下载
$("#export").click(function () {
    window.location.href = "/supplyCard/supplyCardBalanceDownLoad?" + $("#supplycardBalanceForm").serialize()
})